<template>
  <div>
    <div style="margin-bottom: 20px">
      {{ leftClick == 1 ? "主要信息" : "整体信息" }}
    </div>
    <el-form v-if="leftClick == 1" ref="formRef" :model="form">
      <div class="inlineCss">
        <el-form-item label="姓名">
          <el-input v-model="form.name"></el-input>
        </el-form-item>
        <el-form-item label="性别">
          <el-input v-model="form.sex"></el-input>
        </el-form-item>
        <el-form-item label="出生年月">
          <el-date-picker
            v-model="form.birthday"
            type="date"
            placeholder="选择日期"
          ></el-date-picker>
        </el-form-item>
        <el-form-item label="当前工作情况">
          <el-select v-model="form.work" multiple placeholder="请选择">
            <el-option label="学生" value="1"></el-option>
            <el-option label="老师" value="2"></el-option>
          </el-select>
        </el-form-item>
      </div>
      <el-form-item label="标准电子照片">
        <div>
          <el-upload
            list-type="picture-card"
            class="upload-demo"
            action="/api/upload"
            :file-list="form.imageUrl"
          >
            <img v-if="form.imageUrl" :src="form.imageUrl" class="avatar" />
            <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
          </el-upload>
          <span class="imgtext"
            >白底一寸彩照,命名格式:姓名-身份证号,不大于20kb</span
          >
        </div>
      </el-form-item>
      <div style="margin-bottom: 20px">详细信息</div>
      <el-form-item label="考生详细信息">
        <div>
          <el-upload
            class="upload-demo"
            action="/api/upload"
            :file-list="form.imageUrl"
          >
            <el-button type="primary">上传文件</el-button>
          </el-upload>
          <span class="imgtext"
            >支持格式:.rar .zip .doc .docx .pdf,单个文件不能超过20mb</span
          >
        </div>
      </el-form-item>
    </el-form>
    <el-form v-if="leftClick == 2" ref="formRef" :model="form">
      <div class="inlineCss">
        <el-form-item label="报名人数">
          <el-input v-model="form.number"></el-input>
        </el-form-item>
        <el-form-item label="职业工种">
          <el-input v-model="form.gz"></el-input>
        </el-form-item>
        <el-form-item label="职业等级">
          <el-input v-model="form.dj"></el-input>
        </el-form-item>
        <el-form-item label="报名需求">
          <el-input v-model="form.xq"></el-input>
        </el-form-item>
      </div>
      <div style="margin-bottom: 20px">详细信息</div>
      <el-form-item label="考生详细信息">
        <div>
          <el-upload
            class="upload-demo"
            action="/api/upload"
            :file-list="form.imageUrl"
          >
            <el-button type="primary">上传文件</el-button>
          </el-upload>
          <span class="imgtext"
            >支持格式:.rar .zip .doc .docx .pdf,单个文件不能超过20mb</span
          >
        </div>
      </el-form-item>
    </el-form>
  </div>
</template>

<script setup>
import { reactive, ref, toRefs } from "vue";
import { Plus } from "@element-plus/icons-vue";
const props = defineProps({
  leftClick: Number,
});
const formRef = ref();
const state = reactive({
  form: {},
});

let { form } = toRefs(state);

const submitForm = () => {
  formRef.value.validate((valid) => {
    if (valid) {
      console.log("提交表单:", form.value);
    }
  });
};
</script>

<style lang="scss" scoped>
.inlineCss {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;

  .el-form-item {
    flex: 1;
    min-width: 200px;
  }
}

.el-form-item {
  margin-bottom: 22px;
}
.imgtext {
  font-size: 12px;
  color: #999;
}
</style>
